package com.zlx.guguanjia.service.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.zlx.guguanjia.entity.SysLog;
import com.zlx.guguanjia.mapper.SysLogMapper;
import com.zlx.guguanjia.service.SysLogService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.StringUtils;

import java.util.List;
import java.util.Map;

/**
 * @Author 周罗校
 * @Description
 * @ClassName SysLogServiceImpl
 * @date 2020.11.09 13:36:11
 * 该版权归周罗校所有，最终解释权以官方为准
 */
@Service
@Transactional
public class SysLogServiceImpl extends BaseServiceImpl<SysLog,Long> implements SysLogService {
    @Autowired
    private SysLogMapper mapper;

    /**
     * @Author 周罗校
     * @Description Propagation.REQUIRES_NEW:每次调用都会创建一个新的事务，防止事物扩散
     * 导致的回滚，导致发生异常后日志无法持久化到
     * @Param [o]
     * @return int
     * @Date 2020.11.09 13:41:12
     **/
    @Override
    @Transactional(propagation = Propagation.REQUIRES_NEW)
    public int insertSelective(SysLog o) {
        return super.insertSelective(o);
    }

    @Override
    public PageInfo<SysLog> selectPage(int start, int pageSize, Map<String,Object> condition) {
        PageHelper.startPage(start,pageSize);
        List<SysLog> sysLogs = mapper.selectPage(condition);
        return new PageInfo<>(sysLogs);
    }
}
